/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package th.manager;

import com.google.inject.Inject;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import th.dao.PengiklananDAO;
import th.model.Pengiklanan;

/**
 *
 * @author fikri
 */
public class PengiklananManager {
    
    @Inject PengiklananDAO pengiklananDAO;
    
    @Inject
    protected com.google.inject.Provider<Session> sessionProvider;
    
    public List<Pengiklanan> senaraiIklan() {
        StringBuilder sb = new StringBuilder();
        sb.append("Select p from Pengiklanan p where p.aktif = :aktif");
        Session session = sessionProvider.get();
        
        Query query = session.createQuery(sb.toString()).setParameter("aktif", "Y");
        return query.list();
        
    }
}
